<?php

namespace Sharks\Core\Make;

use Sharks\Core\AppContext;
use Sharks\Core\Cfg\AppConfig;
use Sharks\Core\Support\Log\ChromeLogger;
use Sharks\Core\Support\Log\Log;
use Sharks\Core\Support\Log\Logging;
use Sharks\Core\Support\Log\MonologFileLogger;

/**
 * 日志模块初始化
 * 依赖：
 *     AppConfigMaker
 */
class LoggingMaker extends Maker {

    public function dev(AppContext $app) {
        foreach (AppConfig::get("logging.provider", array()) as $provider) {

            $providerName = "\\Sharks\\Core\\Support\\Log\\" . ucfirst($provider) . "Logger";
            if (!class_exists($providerName)) {
                continue;
            }
            $p = new $providerName;
            Log::register($p);
        }
    }

    public function server(AppContext $app) {
//        Log::init($app->path->app->storage, AppConfig::get('log', array()));
    }

    public function makers() {
        return array(AppConfigMaker::class);
    }
}